//package cn.microservices.cloud.system.service.stream;
//
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.messaging.Message;
//import org.springframework.stereotype.Component;
//import reactor.core.publisher.Flux;
//import reactor.core.publisher.Mono;
//
//import java.util.function.Consumer;
//import java.util.function.Function;
//
//@Component
//public class ReceiveMessage {
//
//    // 第一种方式(官方推荐)
//    @Bean
//    public Function<Flux<Message<String>>, Mono<Void>> consumerEvent() {
//        return flux -> flux.map(message -> {
//            System.out.println(message.getPayload());
//            return message;
//        }).then();
//    }
////
////    // 第二种方式
////// 注意使用Flux 要调用 subscribe 不然这个方法不会被消费
////    @Bean
////    public Consumer<Flux<Message<String>>> consumerEvent() {
////        return flux -> flux.map(message -> {
////            System.out.println(message.getPayload());
////            return message;
////        }).subscribe();
////    }
////    // 或
////    @Bean
////    public Consumer<Message<String>> consumerEvent() {
////        return message -> System.out.println(message.getPayload());
////    }
//}
